﻿<Window x:Class="ShareDeployed.Mailgrabber.View.LoginView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
		xmlns:b="clr-namespace:ShareDeployed.Mailgrabber.Behaviour"
		xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
        Title="Login" Height="200" Width="300"
		WindowStartupLocation="CenterOwner" WindowStyle="ToolWindow"
		DataContext="{Binding Source={StaticResource Locator}, Path=LoginVM}" ShowInTaskbar="False"
		FocusManager.FocusedElement="{Binding ElementName=txtLogin}">
	<i:Interaction.Triggers>
		<i:EventTrigger EventName="Closing">
			<cmd:EventToCommand Command="{Binding ClosingCommand}"/>
		</i:EventTrigger>
	</i:Interaction.Triggers>
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="0.6*"/>
			<ColumnDefinition/>
		</Grid.ColumnDefinitions>
		<TextBlock Text="Login:" VerticalAlignment="Center"/>
		<TextBox Text="{Binding LoginData.LoginName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" VerticalAlignment="Center" 
				 x:Name="txtLogin"/>

		<TextBlock Text="Password:" VerticalAlignment="Center" Grid.Row="1"/>
		<PasswordBox PasswordChar="*" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center">
			<i:Interaction.Behaviors>
				<b:PassworBoxBehavior PasswordValue="{Binding LoginData.Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
			</i:Interaction.Behaviors>
		</PasswordBox>

		<TextBlock Text="Save credentials:" Grid.Row="2" VerticalAlignment="Center" />
		<CheckBox IsChecked="{Binding LoginData.SaveCredentials, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" />

		<Button Command="{Binding DoLoginCommand}" Grid.Row="3" Grid.ColumnSpan="2">Login</Button>
	</Grid>
</Window>
